<!--
 * @description  : 实地核查登记
 * @descriptionDetail: 实地核查登记
 * @copyright    : 浙江烟草
 * @author       : lt
 * @create       : 2022-09-27 09:58:58
-->

<template>
  <view>
    <u-form-item :label="params.label" label-position="top" :required="true">
      <u-input type="text" placeholder="请输入" v-model="itemData" />
    </u-form-item>
    <view v-for="(it, idx) in params.listDatas" :key="idx">
      <u-form-item label="">
        <u-row gutter="2">
          <u-col span="4">
            {{ it.productName }}
          </u-col>
          <u-col span="3">
            <u-input v-model="it.storageAmt" />
          </u-col>
          <u-col span="5">
            最近订购量{{ it.orderAmt }}条
          </u-col>
        </u-row>
      </u-form-item>
    </view>
    <u-form-item label="库存照片" label-position="top">
      <m-upload
        index="picList"
        :width="150"
        :height="150"
        :fileList="picList"
        :uploadParam="{'fiGroupCode':'zmng-images', 'bizId': params.bizUuid}"
        @on-list-change="getImgs"
      ></m-upload>
    </u-form-item>
  </view>
</template>
<script>
import commonService from '@/service/internal/common.service';
import mUpload from "@/components/m-upload.vue";
export default {
  components: {mUpload,}, 
  props: {
    params:{
      label: String,
      listDatas: Array,
      bizUuid: String,
    },
  },
  data() {
    return {
      products:this.params.listDatas,
      itemData: '', // 总库存
      unusualFiles: '', // 库存照片id
      picList: [], // 照片对象 
      errorMessage:'库存为必填项',
    };
  },
  created(){
    this.renderImages();
  },
  methods: {
    renderImages(){
      commonService.findFilesByBizId(this.params.bizUuid).then(r => {
        r.data.forEach(i => {
          i.src = `${commonService.downloadFile}?fileId=${i.gfiId}&tk=${uni.getStorageSync("tk")}`;
          i.filePath = i.src;
        });
        this.picList = r.data;
      });
    },
    getImgs(list, pos) {
      this.picList = [...list,];
      let name = this.picList.map(it => it.gfiId);
      this.unusualFiles = name.join(',');
    },
  },
};
</script>
<style lang="scss" scoped>

</style>